package cn.lingyangwl.agile.infra.weixin.mp.controller;

import cn.lingyangwl.framework.core.response.Resp;
import cn.lingyangwl.agile.infra.weixin.mp.model.entity.MpAutoReply;
import cn.lingyangwl.agile.infra.weixin.mp.model.rqrs.MpAutoReplyPageReq;
import cn.lingyangwl.agile.infra.weixin.mp.model.rqrs.MpAutoReplySaveReq;
import cn.lingyangwl.agile.infra.weixin.mp.model.rqrs.MpAutoReplyUpdateReq;
import cn.lingyangwl.agile.infra.weixin.mp.service.MpAutoReplyService;
import cn.lingyangwl.agile.ram.ActionType;
import cn.lingyangwl.agile.ram.RamResource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公众号消息自动回复
 * 
 * @author shenguangyang
 */
@Api(tags = "公众号消息自动回复")
@RestController
@RequestMapping("/mpAutoReply")
public class MpAutoReplyController {
    @Resource
    private MpAutoReplyService mpAutoReplyService;

    @ApiOperation(value = "分页公众号消息自动回复列表")
    @RamResource(action = "weixin:mpAutoReply:query", name = "查询公众号消息自动回复", type = ActionType.READ)
    @GetMapping("/pageMpAutoReply")
    public Resp<IPage<MpAutoReply>> pageAutoReply(@Validated MpAutoReplyPageReq query) {
        return Resp.ok(mpAutoReplyService.pageAutoReply(query));
    }

    @ApiOperation(value = "查询公众号消息自动回复详情")
    @RamResource(action = "weixin:mpAutoReply:query", name = "查询公众号消息自动回复", type = ActionType.READ)
    @GetMapping("/getMpAutoReplyById")
    public Resp<MpAutoReply> getMpAutoReplyById(@RequestParam(value = "id") Long id) {
        return Resp.ok(mpAutoReplyService.getAutoReplyById(id));
    }
  
    /**
     * 保存 公众号消息自动回复
     */
    @ApiOperation(value = "保存公众号消息自动回复")
    @RamResource(action = "weixin:mpAutoReply:save", name = "保存公众号消息自动回复", type = ActionType.WRITE)
    @PostMapping("/saveMpAutoReply")
    public Resp<?> saveMpAutoReply(@Validated @RequestBody MpAutoReplySaveReq rq) {
        return Resp.ok(mpAutoReplyService.saveAutoReply(rq));
    }
  
    /**
     * 更新 公众号消息自动回复
     */
    @ApiOperation(value = "更新公众号消息自动回复")
    @RamResource(action = "weixin:mpAutoReply:update", name = "更新公众号消息自动回复", type = ActionType.WRITE)
    @PostMapping("/updateMpAutoReply")
    public Resp<?> updateMpAutoReply(@Validated @RequestBody MpAutoReplyUpdateReq rq) {
        return Resp.ok(mpAutoReplyService.updateAutoReplyById(rq));
    }
  
    /**
     * 批量删除 公众号消息自动回复
     */
    @ApiOperation(value = "删除公众号消息自动回复")
    @RamResource(action = "weixin:mpAutoReply:delete", name = "删除公众号消息自动回复", type = ActionType.WRITE)
    @DeleteMapping("/batchDeleteMpAutoReply")
    public Resp<?> deleteBatch(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(mpAutoReplyService.deleteAutoReplyByIds(ids));
    }
  
    /**
     * 删除 公众号消息自动回复
     */
    @ApiOperation(value = "删除公众号消息自动回复")
    @RamResource(action = "weixin:mpAutoReply:delete", name = "删除公众号消息自动回复", type = ActionType.WRITE)
    @DeleteMapping("/deleteMpAutoReply")
    public Resp<?> delete(@RequestParam(value = "id") Long id) {
        return Resp.ok(mpAutoReplyService.deleteAutoReplyById(id));
    }
}
